package course.java.simulation.client;

import com.alibaba.fastjson.JSON;
import course.java.simulation.bankandexcute.RequestObject;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.LinkedBlockingQueue;

/**
 * 发送交易指令
 */
@Slf4j
public class SendTradingExcute implements Runnable{
    //实现生产者消费者队列，保证顺序
    private LinkedBlockingQueue blockingTxCommandQueue;

    private RequestObject requestObject;

    @Override
    public void run() {
        try {
            if (blockingTxCommandQueue!=null &&  requestObject!=null) {
                blockingTxCommandQueue.put(requestObject);
            }
        } catch (Exception e) {
            log.error("打印异常数据参数:{}", JSON.toJSONString(requestObject)+"异常信息：{}"+e.getMessage());
        }
    }
}
